//我的回复
Vue.component('my_back', {
	//修改密码组件
	template: '<div class="my_back">\
					<!--名称-->\
					<li class="type_title">我的回复</li>\
					<!--回复列表-->\
					<div class="back_news">\
						<div class="content"  v-for="(item,index) in comments">\
							<!--左侧-->\
							<div>\
								<div>\
									<img :src=" item.HeadImage ? item.HeadImage : \'imgs/icon.jpg\'" alt="" />\
								</div>\
								<span>{{item.Creator}}</span>\
							</div>\
							<!--右侧-->\
							<div>\
								<div class="my_flex my_flex_between">\
									<span>{{item.ContentShort}}</span>\
									<img @click="del(index)" src="imgs/community/del.png" alt="" />\
								</div>\
								<div>来自"<span>{{item.Title}}</span>"</div>\
								<div><span>{{item.CreateTimeText}}</span></div>\
							</div>\
						</div>\
					</div>\
					<div v-if="comments.length<1"><p class="text-center nocontent">暂无内容</p></div>\
					<change-page v-if="comments.length>0" :current_page="page.pageIndex" :page_size="page.pageSize" :page_total="page.pageTotal" @page-change="getPageMyCommentsForApp"></change-page>\
				</div>',
	data: function() {
		return {
			url: {
				getPageMyReplayForApp: '/api/Forum/GetPageMyReplayForApp',
				del: '/api/Forum/DeleteMyForum',
			},
			comments: [],
			page: {
				pageIndex: 1,
				pageSize: 20,
				pageTotal: 0
			}
		}
	},
	mounted: function() {
		this.getPageMyCommentsForApp(this.page.pageIndex, this.page.pageSize);
	},
	methods: {
		getPageMyCommentsForApp: function(curPage, pageSize) {
			var that = this;
			var data = {
				PageIndex: curPage,
				PageSize: pageSize
			};
			globalData.ajaxPost(this.url.getPageMyReplayForApp, data, function(res) {
				var d = res.data;
				if(d == null)
					return;
				globalData.utils.page(that, curPage, res.count);
				for(var i = 0; i < d.length; i++) {
					var h = d[i].HeadImage;
					if(h != null)
						d[i].HeadImage = globalData.constParam.url.baseUrl + "/" + h;
				}
				that.comments = d;
				console.log(res.data)
			})
		},
		//删除回复
		del: function(index) {
			var that = this;
			var d = this.comments[index];
			var data = {
				ID: d.ID
			};
			globalData.ajaxPost(this.url.del, data, function(res) {
				if(res.suc) {
					globalData.utils.alert("删除成功");
					that.comments.splice(index, 1);
				}
			})
		},
		//去详情页
		go_detail: function(item) {
			console.log(item)
			return;
			var obj = {
				id:item.ID
			}
			var url = "forum_datail.html"
			globalData.utils.setUrl(url,obj)
		}
	}
});